package com.cmj.controller;

import com.cmj.domain.ResponseResult;
import com.cmj.domain.dto.TagListDto;
import com.cmj.domain.entity.Tag;
import com.cmj.domain.vo.PageVo;
import com.cmj.domain.vo.TagVo;
import com.cmj.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/content/tag")
public class TagController {

    @Autowired
    private TagService tagService;

    /**
     * Query格式请求参数：
     * pageNum: 页码
     * pageSize: 每页条数
     * name：标签名
     * remark：备注
     * @param pageNum
     * @return
     */
    @GetMapping("/list")
    public ResponseResult<PageVo> list(Integer pageNum, Integer pageSize, TagListDto tagListDto){
        return tagService.pageTagList(pageNum,pageSize,tagListDto);
    }

    @PostMapping
    public ResponseResult addTag(@RequestBody Tag tag){
        return tagService.addTag(tag);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delTag(@PathVariable("id") Long[] id){
        return tagService.delTag(id);
    }

    @GetMapping("/{id}")
    public ResponseResult<TagVo> getTag(@PathVariable("id") Long id){
        return tagService.getTag(id);
    }

    @PutMapping
    public ResponseResult updateTag(@RequestBody Tag tag){
        return tagService.updateTag(tag);
    }

    @GetMapping("/listAllTag")
    public ResponseResult getListAllTag(){
        return tagService.getListAllTag();
    }
}